package top.lishuoboy.hibernate.validator.a4;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;

@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Accessors(chain = true)
public class Car {
    @NotNull
    private String manufacturer;

    @Size(min = 2, max = 14, message = "车牌号licensePlate “${validatedValue}” 的个数必须在{min}和{max}之间")
    private String licensePlate;

    @Min(value = 2, message = "seatCount ${validatedValue}  must be at least {value} seat${value > 1 ? 's' : ''}")
    private int seatCount;

    @DecimalMax(value = "350", message = "最高速度topSpeed ${formatter.format('%1$.2f', validatedValue)} 必须小于${inclusive == true ? '或等于' : ''} {value}")
    private double topSpeed;

    @DecimalMax(value = "100000", message = "价格price ${validatedValue} 必须小于${inclusive == true ? '或等于' : ''}{value}")
    private BigDecimal price;

}